﻿
@{
    ViewBag.Title = "对应角色人员信息";
}
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <table id="LAY-role-list" lay-filter="LAY-role-list"></table>
            <script type="text/html" id="table-content-list">
                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-user"></i>移除</a>
            </script>
        </div>
    </div>
</div>
<script type="text/javascript">
    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table'], function () {
        var table = layui.table
            , form = layui.form
            , $ = layui.$
            , admin = layui.admin;
        //数据绑定
        table.render({
            elem: '#LAY-role-list'
            , url: '/Role/GetListByRole?RoleId=@Request.QueryString["RoleId"]' //模拟接口
            , method: 'post'
            , cols: [[
                { type: 'checkbox', fixed: 'left' }
                , { field: 'Name', title: '姓名', width: "10%" }
                , { field: 'Code', title: '代码', width: "15%" }
                , { field: 'DeptName', title: '部门', width: "15%" }
                , { field: 'MemberTypeStr', title: '类别', width: "8%" }
                , { field: 'Status', title: '状态', width: "15%" }
                , { field: 'right', title: '操作', width: 200, align: 'center', fixed: 'right', toolbar: '#table-content-list' }
            ]]
            , page: true
            , limit: 10
            , limits: [10, 15, 20, 25, 30]
            , text: { none: '暂无数据' }
        });

        //监听工具条
        table.on('tool(LAY-role-list)', function (obj) {
            var data = obj.data;
            if (obj.event === 'del') {
                layer.confirm('确定移除该用户？', function (index) {
                    admin.req({
                        url: '/Role/RemoveUserRole' //实际使用请改成服务端真实接口
                        , method: 'post'
                        , data: "userCode=" + data.Code + "&RoleId=@Request.QueryString["RoleId"]"
                        , done: function (res) {
                            //登入成功的提示与跳转
                            layer.msg(res.msg, {
                                offset: '50px'
                                , icon: 1
                                , time: 3000
                            }, function () {
                                table.reload('LAY-role-list'); //重载表格
                            });
                        }
                    });
                });
            }
        });
        //监听搜索
        form.on('submit(LAY-role-search)', function (data) {
            //执行重载
            table.reload('LAY-role-list');
        });
    });
</script>